﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using MapWindow;
using MapWindow.Data;

namespace HydroAnalyzer
{
    public partial class frmEnterQuery : Form
    {
        public frmEnterQuery()
        {
            InitializeComponent();
        }

        private void radBtn_CheckedChanged(object sender, EventArgs e)
        {
           //this.map1.Layers.Add(@"C:\\Dev\\hydrodesktop\\Maps\\BaseData\\counties.shp");
           FeatureSet FeatureFile = new FeatureSet();
           OpenFileDialog openFileDialog1 = new OpenFileDialog();
           openFileDialog1.InitialDirectory = "c:\\";
           openFileDialog1.Filter = "shp files (*.shp)|*.shp|All files (*.*)|*.*";
           openFileDialog1.FilterIndex = 2;
           openFileDialog1.RestoreDirectory = true;

           if (openFileDialog1.ShowDialog() == DialogResult.OK)
           {
               try
               {
                   //Add Features
                   FeatureFile.Open(openFileDialog1.FileName);
                   this.map1.Layers.Add(FeatureFile);
                   //Add Attributes
                   DataTable attr = new DataTable();
                   attr = FeatureFile.DataTable;
                   dataGridView1.DataSource = attr;

               }
               catch (Exception ex)
               {
                   MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
               }
           }

        }

        private void frmEnterQuery_Load(object sender, EventArgs e)
        {
            label1.Text = "Choose Input Data";
            Point position = new Point();
            position.X = (panel1.Width / 2) - (label1.Width / 2);
            position.Y = (panel1.Height / 2) - (label1.Height / 2);
            label1.Location = position;
        }

        private void butNext_Click(object sender, EventArgs e)
        {

        }
    }
}
